package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class AddBook implements Operation{
    @Override
    public void act(BookList bookList) {
        System.out.println("增加书籍！");
        Scanner s = new Scanner(System.in);
        int currentSize = bookList.getUsedSize();
        System.out.println("请输入书籍名字：");
        String bookName = s.nextLine();
        System.out.println("请输入书籍作者：");
        String author = s.nextLine();
        System.out.println("请输入书籍价格：");
        double price = s.nextDouble();
        s.nextLine();
        System.out.println("请输入书籍类型：");
        String type = s.nextLine();
        Book book = new Book(bookName, author, price, type);
        bookList.setBook(currentSize, book);
        bookList.setUsedSize(currentSize + 1);
        System.out.println("增加完成");
    }
}
